package com.easy.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.easy.entity.Staff;
import com.easy.service.StaffService;
import com.easy.utils.LayData;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("staff")
public class StaffController {

    @Autowired
    StaffService service;

    //查询
    @RequestMapping("getList")
    public LayData getList(@RequestParam Map params) {
        // layui传递的参数 page,limit每页显示几条
        // System.out.println(params);
        // {code,msg,count,data}格式
        // count是查询数据的总条数
        // list 是当前也显示的数据
      
        int count = service.getCount(params);
        List<Staff> list = service.getList(params);
        LayData ld = new LayData(count, list);
        return ld;
        //

    }

    //删除
    @RequestMapping("del")
    public int del(@RequestParam Map params) {

        return service.del(params);

    }

    //添加
    @RequestMapping("add")
    public int add(@RequestParam Map params) {


        return service.add(params);

    }

    //判断用户名是否重复
    @RequestMapping("loginnamerepeat")
    public boolean loginNameRepeat(@RequestParam Map params) {

        return service.loginNameRepeat(params);

    }

    //编辑
    @RequestMapping("edit")
    public int edit(@RequestParam Map params) {

        return service.edit(params);

    }

    //恢复
    @RequestMapping("recover")
    public int recover(@RequestParam Map params) {

        return service.recover(params);

    }

    //辞退
    @RequestMapping("dismissed")
    public int dismissed(@RequestParam Map params) {

        return service.dismissed(params);

    }

    //修改密码
    @RequestMapping("resetpass")
    public boolean resetpass(@RequestParam Map<String,String> params, HttpSession session) {
//让其失效(重置密码后)
        //session.invalidate();
        return service.resetpass(params, session);

    }


}
